using UnityEngine;

public class CanvasWorldSpaceResize : MonoBehaviour
{
	public Vector2 referenceResolution = new Vector2(720f, 1280f);

	[HideInInspector]
	public Vector2 scale;

	private void Start()
	{
		Camera camera = UnityEngine.Object.FindObjectOfType<Camera>();
		RectTransform component = GetComponent<RectTransform>();
		float num = camera.orthographicSize * 2f;
		float num2 = num * (float)Screen.width / (float)Screen.height;
		component.sizeDelta = new Vector3(num2 * 100f, num * 100f);
		component.position = new Vector3((0f - num2) / 2f, num / 2f);
		scale = new Vector2((float)Screen.width / referenceResolution.x, (float)Screen.height / referenceResolution.y);
	}

	public GameObject CreateGameObjectAndSetPosition(GameObject prefab, Vector3 position, string name)
	{
		GameObject gameObject = CreateGameObject(prefab, name);
		gameObject.transform.localPosition = position;
		return gameObject;
	}

	public GameObject CreateGameObject(GameObject prefab, string name)
	{
		GameObject gameObject = UnityEngine.Object.Instantiate(prefab, base.transform);
		if (name != string.Empty)
		{
			gameObject.name = name;
		}
		return gameObject;
	}
}
